package com.sjq.common.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sjq.common.dao.UserDao;
import com.sjq.common.entity.User;
import com.sjq.common.service.LoginService;

@Service("loginService")
public class LoginServiceImpl implements LoginService {
    @Autowired
    private UserDao userDao;


    @Override
    public void modifyUser(User user) {
        userDao.updateUser(user);
    }

    @Override
    public User checkLogin(String acccountName, String password) {

        acccountName = (acccountName == null) ? "" : acccountName;
        password = (password == null) ? "" : password;

        User user = userDao.getUserByAccount(acccountName);
        if (user == null) return null;

        if (acccountName.equals(user.getJH()) && password.equals(user.getYHMM())) {
        	
            return user;
        }

        return null;
    }

	@Override
	public User checkPkiLogin(String acountName) {
	
	        User user = userDao.getUserByGmsfhm(acountName);
	        if (user == null) return null;

	        if (acountName.equals(user.getYHM())) {
	        	
	            return user;
	        }

	        return null;
	}

    	

}
